package cn.taoshop.index.action;

import cn.taoshop.product.service.ProductService;
import cn.taoshop.product.vo.Product;

import java.util.List;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

// 首页访问的Action
 
public class IndexAction extends ActionSupport{
	// 注入商品的Service
	private ProductService productService;
	
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}


	public String execute(){
		// 查询热门商品:
		List<Product> hList = this.productService.findHot();
		// 保存到值栈中:
		ActionContext.getContext().getValueStack().set("hList", hList);
		// 查询最新商品:
		List<Product> nList = this.productService.findNew();
		// 保存到值栈中:
		ActionContext.getContext().getValueStack().set("nList", nList); 
		return "index";
	}

}
